package easier.websocket;

import java.net.URI;
import java.util.Objects;
import java.util.Scanner;

public class ClientTest {

    public static void main( String[] args ) {

        URI uri = URI.create( "ws://127.0.0.1:8889" );
        WebSocketClientImpl client = new WebSocketClientImpl( uri );
        try {
            client.connectBlocking();
            client.send( "hello world" );

            Scanner scanner = new Scanner( System.in );
            while ( true ) {
                String s = scanner.nextLine();
                if ( Objects.equals( s, "exit" ) ) {
                    break;
                } else {
                    client.send( s );
                }
            }
            client.closeBlocking();
        } catch ( Exception e ) {
            e.printStackTrace();
        }

    }
}
